home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Configuration / TE3Click 1.0 folder / Source Code / TE3Click init.c next >
C/C++ Source or Header  |  1994-03-08  |  1KB  |  62 lines

  1. /*
  2.  *    TE3CLICK PROJECT
  3.  *    INIT CODE
  4.  *
  5.  *    Copyright © 1994 Marco Piovanelli
  6.  *    All Rights Reserved
  7.  */
  8.  
  9.  
  10. /*    TRAP DEFINITIONS */
  11.  
  12. #define        _GetOSTrapAddress        dc.w 0xA346
  13. #define        _SetOSTrapAddress        dc.w 0xA247
  14. #define        _GetToolTrapAddress        dc.w 0xA746
  15. #define        _SetToolTrapAddress        dc.w 0xA647
  16. #define        _NewPtrSysClear            dc.w 0xA71E
  17.  
  18. /*    miscellaneous constants */
  19.  
  20. #define        kPatchType                'PATC'
  21. #define        kPatchID                2139
  22.  
  23. void main(void)
  24. {
  25.     asm {
  26.         
  27.         clr.l -(sp)                            ; 
  28.         move.l #kPatchType, -(sp)            ; 
  29.         move.w #kPatchID, -(sp)                ; 
  30.         _Get1Resource                        ; get patch resource
  31.         move.l (sp)+, d2                    ; 
  32.         beq.s @exit                            ; NIL resource handle: exit
  33.         
  34.         movea.l d2, a0                        ; 
  35.         _GetHandleSize                        ; get patch size
  36.         move.l d0, d1                        ; 
  37.         
  38.         _NewPtrSysClear                        ; allocate a block this size in sys heap
  39.         bne.s @exit                            ; couldn't allocate memory: exit
  40.         
  41.         movea.l d2, a1                        ; 
  42.         movea.l (a1), a1                    ; 
  43.         exg a0, a1                            ; 
  44.         move.l d1, d0                        ; 
  45.         _BlockMove                            ; copy patch to sys block
  46.         
  47.         move.w #0xA9D4, d0                    ; 
  48.         _GetToolTrapAddress                    ; get _TEClick address
  49.         move.l a0, 2(a1)                    ; copy original address to patch header
  50.  
  51.         move.w #0xA9D4, d0                    ; 
  52.         movea.l a1, a0                        ; 
  53.         _SetToolTrapAddress                    ; install patch
  54.         
  55.         move.l d2, -(sp)                    ; 
  56.         _ReleaseResource                    ; throw away patch resource
  57.  
  58. @exit                                        ; implicit rts
  59.  
  60.     }
  61. }
  62.